package com.security.gateway.util;

import com.security.gateway.handler.RestErrorHandler;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;


/**
 * @Author yanggld
 * @Date 2020/3/12-11:08
 */
public class RestUtil {
    public static String getCause(RestTemplate restTemplate) {
        ResponseErrorHandler responseErrorHandler = restTemplate.getErrorHandler();
        if (responseErrorHandler instanceof RestErrorHandler) {
            RestErrorHandler errorHandler = (RestErrorHandler) responseErrorHandler;
            return errorHandler.getCause();
        }
        return null;
    }
}
